﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using WebChatApi.Common;

namespace WebChatApi.Common.Calendar
{
    /// <summary>
    /// 
    /// </summary>
    [DataContract]
    [KnownType(typeof(CalendarEvent))]
    [KnownType(typeof(CalendarTodo))]
    public class CalendarDay
    {
        #region Properties

        /// <summary>
        /// Gets or sets the date.
        /// </summary>
        /// <value>
        /// The date time.
        /// </value>
        [DataMember]
        public DateTime Date
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets a value indicating whether this instance is workday.
        /// </summary>
        /// <value>
        /// <c>true</c> if this instance is workday; otherwise, <c>false</c>.
        /// </value>
        [DataMember]
        public bool IsWorkday
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the events.
        /// </summary>
        /// <value>
        /// The events.
        /// </value>
        [DataMember]
        public List<CalendarEvent> Events
        {
            get;
            set;
        }

        #endregion

        /// <summary>
        /// Initializes a new instance of the <see cref="CalendarDay"/> class.
        /// </summary>
        public CalendarDay()
        {
            DayOfWeek dayOfWeek = this.Date.DayOfWeek;
            this.IsWorkday = dayOfWeek != DayOfWeek.Sunday && dayOfWeek != DayOfWeek.Saturday;
            this.Events = new List<CalendarEvent>();
        }

        /// <summary>
        /// Gets the week by day.
        /// </summary>
        /// <param name="firstDayOfWeek">The first day of week.</param>
        /// <returns></returns>
        public CalendarWeek GetWeek(DayOfWeek firstDayOfWeek)
        {
            CalendarWeek week = new CalendarWeek(this.Date, firstDayOfWeek);
            return week;
        }
    }
}
